// 首先针对这个样式类里面，定义了一系列的样式变量
.duyi-button {
  --duyi-button-font-weight: var(--duyi-font-weight-primary);
  --duyi-button-border-color: var(--duyi-border-color);
  --duyi-button-bg-color: var(--duyi-fill-color-blank);
  --duyi-button-text-color: var(--duyi-text-color-regular);
  --duyi-button-disabled-text-color: var(--duyi-disabled-text-color);
  --duyi-button-disabled-bg-color: var(--duyi-fill-color-blank);
  --duyi-button-disabled-border-color: var(--duyi-border-color-light);
  --duyi-button-hover-text-color: var(--duyi-color-primary);
  --duyi-button-hover-bg-color: var(--duyi-color-primary-light-9);
  --duyi-button-hover-border-color: var(--duyi-color-primary-light-7);
  --duyi-button-active-text-color: var(--duyi-button-hover-text-color);
  --duyi-button-active-border-color: var(--duyi-color-primary);
  --duyi-button-active-bg-color: var(--duyi-button-hover-bg-color);
  --duyi-button-outline-color: var(--duyi-color-primary-light-5);
  --duyi-button-active-color: var(--duyi-text-color-primary);
}

.duyi-button {
  // 接下来再来书写基本的样式
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  height: 40px;
  background-color: var(--duyi-button-bg-color);
  border: var(--duyi-border);
  border-color: var(--duyi-button-border-color);
  color: var(--duyi-button-text-color);
  appearance: none;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  margin: 0;
  transition: 0.1s;
  font-weight: var(--duyi-button-font-weight);
  user-select: none;
  vertical-align: middle;
  padding: 12px 20px;
  font-size: var(--duyi-font-size-base);
  border-radius: var(--duyi-border-radius-base);
  &:hover,
  &:focus {
    color: var(--duyi-button-hover-text-color);
    border-color: var(--duyi-button-hover-border-color);
    background-color: var(--duyi-button-hover-bg-color);
    outline: none;
  }
  &:active {
    color: var(--duyi-button-active-text-color);
    border-color: var(--duyi-button-active-border-color);
    background-color: var(--duyi-button-active-bg-color);
    outline: none;
  }
  &.is-round {
    border-radius: var(--duyi-border-radius-round);
  }
  &.is-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    padding: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  // 禁用相关的样式
  &.is-disabled,
  &.is-disabled:hover,
  &.is-disabled:focus,
  &[disabled],
  &[disabled]:hover,
  &[disabled]:focus {
    color: var(--duyi-button-disabled-text-color);
    cursor: not-allowed;
    background-image: none;
    background-color: var(--duyi-button-disabled-bg-color);
    border-color: var(--duyi-button-disabled-border-color);
  }
  [class*='duyi-icon'] + span {
    margin-left: 6px;
    position: relative;
    bottom: 2px;
  }
}

@each $val in primary, success, warning, info, danger {
  // 这是一种非常灵活的方式，通过挂上去一些类，改变 CSS 变量所对应的值
  .duyi-button--#{$val} {
    --duyi-button-text-color: var(--duyi-color-white);
    --duyi-button-bg-color: var(--duyi-color-#{$val});
    --duyi-button-border-color: var(--duyi-color-#{$val});
    --duyi-button-outline-color: var(--duyi-color-#{$val}-light-5);
    --duyi-button-active-color: var(--duyi-color-#{$val}-dark-2);
    --duyi-button-hover-text-color: var(--duyi-color-white);
    --duyi-button-hover-bg-color: var(--duyi-color-#{$val}-light-3);
    --duyi-button-hover-border-color: var(--duyi-color-#{$val}-light-3);
    --duyi-button-active-bg-color: var(--duyi-color-#{$val}-dark-2);
    --duyi-button-active-border-color: var(--duyi-color-#{$val}-dark-2);
    --duyi-button-disabled-text-color: var(--duyi-color-white);
    --duyi-button-disabled-bg-color: var(--duyi-color-#{$val}-light-5);
    --duyi-button-disabled-border-color: var(--duyi-color-#{$val}-light-5);
  }
  // 如果挂了 is-plain 这个，那么同样是改变一些 CSS 变量的值
  .duyi-button--#{$val}.is-plain {
    --duyi-button-text-color: var(--duyi-color-#{$val});
    --duyi-button-bg-color: var(--duyi-color-#{$val}-light-9);
    --duyi-button-border-color: var(--duyi-color-#{$val}-light-5);
    --duyi-button-hover-text-color: var(--duyi-color-white);
    --duyi-button-hover-bg-color: var(--duyi-color-#{$val});
    --duyi-button-hover-border-color: var(--duyi-color-#{$val});
    --duyi-button-active-text-color: var(--duyi-color-white);
  }
}

// 针对 duyi-button-large 以及 duyi-button-small 书写相应的样式即可
.duyi-button--large {
  --duyi-button-size: 50px;
  height: var(--duyi-button-size);
  padding: 12px 19px;
  font-size: var(--duyi-font-size-base);
  border-radius: var(--duyi-border-radius-base);
}
.duyi-button--small {
  --duyi-button-size: 24px;
  height: var(--duyi-button-size);
  padding: 5px 11px;
  font-size: 12px;
  border-radius: calc(var(--duyi-border-radius-base) - 1px);
}
